<template>
    <div>
        <el-row>
            <el-col :span="4">
                <el-input placeholder="请输入账号" v-model="input" clearable>
                </el-input>
            </el-col>
            <el-button style="margin-right: 900px;" type="primary" @click="selectadmin">
                搜索
            </el-button>
        </el-row>
        <el-row style="margin-top: 20px;">
            <el-col>
                <template>
                    <el-table :data="page.list" style="width: 100%">
                        <el-table-column prop="platformAccount" label="申请人账号" width="180">
                        </el-table-column>
                        <el-table-column prop="address" label="操作">
                            <div style="display: flex;" slot-scope="scope">
                                <el-button type="primary" @click="ok(scope.row)">通过</el-button>
                                <el-button type="danger" style="margin-left: 20px;" @click="notok(scope.row)">拒绝</el-button>
                            </div>
                        </el-table-column>
                    </el-table>
                </template>
            </el-col>
        </el-row>
        <!-- 分页按钮 -->
        <el-row>
            <el-col :span="24">
                <el-pagination background layout="total, prev, pager, next" :page-size="page.size" :total="page.total"
                    @current-change="changePageNum">
                </el-pagination>
            </el-col>
        </el-row>
    </div>
</template>

<script>
import router from '../router';

export default {
    name: "PlatformBidAdmin",
    data() {
        return {
            input: "",
            platformAccounts: "",
            page: {},
            logoUrl: "../../static/images/system/woniu.png",
            pageNum: "",
            pageSize: "",
        };
    },
    methods: {
        notok(obj){
            let platformIds = obj.platformId;
            this.$http.get("/platform/platformAccount/delplatformState", {
                params: {
                    platformId: platformIds
                }
            }).then(resp => {
                alert(resp.data.message);
                this.loadAllBidAdmin();
            });
        },
        ok(obj) {
            let platformIds = obj.platformId;
            this.$http.get("/platform/platformAccount/updateplatformState", {
                params: {
                    platformId: platformIds
                }
            }).then(resp => {
                alert(resp.data.message);
                this.loadAllBidAdmin();
            });
        },
        selectadmin() {
            if (this.input) {
                this.$http.get("/platform/platformAccount/LoadAdminByPlatformAccount", {
                    params: {
                        platformAccounts: this.input
                    }
                }).then(resp => {
                    console.log(resp);
                    this.page.list = [resp.data.data]; // 将返回的单个对象转换成数组赋值给page.list
                    this.page.total = 1; // 更新total属性
                    this.page.size = 1; // 更新size属性（假设每页显示10条数据，根据实际情况修改）
                });
            } else {
                this.loadAllBidAdmin();
            }
        },
        changePageNum(pageNum) {
            this.pageNum = pageNum;
            this.loadAllBidAdmin();
        },
        loadAllBidAdmin() {
            if (!this.pageNum) {
                this.pageNum = 1;
            }
            if (!this.pageSize) {
                this.pageSize = 6; // 默认每页显示10条数据，根据实际情况修改
            }
            this.$http.get("/platform/platformAccount/LoadALLplatform", {
                params: {
                    pageNum: this.pageNum,
                    pageSize: this.pageSize
                }
            }).then(resp => {
                console.log(resp)
                this.page = resp.data.data;
            });
        }
    },
    created() {
        this.loadAllBidAdmin()
    },
    components: { router }
}
</script>

<style scoped>
html,
body {
    height: 100%;
}
</style>